<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="layui/css/layui.css"  media="all">
    <link rel="import" href="indexs.html" id="page1">
    <style>

    </style>
    <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>
<body>
<script type="text/javascript">
    document.write(page1.import.body.innerHTML);
</script>
<div style="background-color: #00F7DE;height: 120px;width: 100%;position: absolute;float: left;" id="showStudent">
    <img src="image/timg1.jpg " style="width: 100%; height: 120px;">
</div>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
    <div class="layui-side layui-bg-black" style="margin-top: 150px;margin-left: 200px">
        <div class="layui-side-scroll">
            <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
            <ul class="layui-nav layui-nav-tree"  lay-filter="test" style="text-align: center">
                <li style="font-size: 20px">个人中心</li>
                <li class="layui-nav-item" onclick="homePage()">首页</li>
                <li class="layui-nav-item" onclick="Myinformation()">我的信息</li>
            </ul>
        </div>
    </div>
    <div id="details" style="margin-left: 300px;margin-top: 150px;border:2px solid gray;height: 520px;width: 1000px;position: absolute;">
        <!--<div style="width: 90%;height: 65px;border:2px solid gray;position: absolute;right: 0;">
            <div style="width: 120px;height: 30px;margin-top: 15px;margin-left: 30px;">
                <label style="font-size: 20px;color: #40AFFE;">我的信息</label>
            </div>
        </div>
        <form>
            <div style="width: 90%;height: 350px;position: absolute;right: 0;margin-top: 100px;margin-right: 1px;border-bottom: 1px solid gray;">
                <div style="width: 85%;height: 40px;position: absolute;right: 0;margin-top: 50px">
                <label style="font-size: 20px">昵称：</label><input style="width: 300px;height: 30px;" type="text" name="sName" autocomplete="off" id="sName">
                </div>
                <div style="width: 85%;height: 40px;position: absolute;right: 0;margin-top: 120px;margin-right: 18px">
                    <label style="font-size: 20px">用户名：</label><label>123213</label>
                </div>
                <div style="width: 85%;height: 40px;position: absolute;right: 0;margin-top: 180px;margin-right: 40px">
                    <label style="font-size: 20px">我的签名：</label><textarea style="width: 500px"  class="layui-textarea" name="sIntroduction" id="sIntroduction"></textarea>
                </div>
            </div>
        </form>
        <div style="width: 120px;height: 40px;position: absolute;right: 0;bottom: 0;margin-bottom: 50px;margin-right: 420px">
            <button type="submit" class="layui-btn layui-btn-normal" style="width: 100px">保存</button>
        </div>-->
    </div>
</div>

<script src="layui/layui.js" charset="utf-8"></script>
<script src="js/jquery.min.js" charset="utf-8"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
    //JavaScript代码区域
    layui.use('element', function(){
        var element = layui.element;

    });
$(document).ready(function () {
    homePage();

    $("#submit").click (function(){
        upudateData();
    })
});

    function homePage() {
        $.ajax({
            url:"Mydata/showData",
            data:{
              sId:1
            },
            success:function (data) {
                var content = "";
                for(var i = 0; i < data.length; i++){
                    content+='<div style="height: 200px;width: 90%;float: right;right:0;position: absolute;">\n' +
                        '            <div class="layui-inline"style="top: 0;position: absolute;margin-left: 30px;float: left;margin-top: 60px">\n' +
                        '                <img src="image/71843cbde75bb01b4290011d457552fd.jpg" class="layui-circle" style="width: 75px;height: 75px;">\n' +
                        '            </div>\n' +
                        '            <div style="height: 100px;width: 86%;right:0;position: absolute;margin-top: 50px">\n' +
                        '                <div style="height: 30px;width: 60%;float: left;margin-top: 5px;font-size: 25px" id="sname">'+data[i].sName+'</div>\n' +
                        '                <div style="height: 30px;width: 60%;float: left;margin-top: 20px;font-size: 20px" id="sintroduction">'+data[i].sIntroduction+'</div>\n' +
                        '            </div>\n' +
                        '        </div>\n' +
                        '        <div style="width: 90.5%;height: 350px;background-color: #00F7DE;position: absolute;bottom: 0;right: 0">\n' +
                        '            <img src="image/timg1.jpg" style="width: 100%;height: 100%;">\n' +
                        '        </div>';
                }
                $("#details").html(content);
            }
        })
    }

    function Myinformation() {
        $.ajax({
            url:"Mydata/showData",
            data:{
              sId:1
            },
            success:function (data) {
                var content = "";
                for(var i = 0; i < data.length; i++){
                    content+='<div style="width: 90%;height: 65px;border:2px solid gray;position: absolute;right: 0;">\n' +
                        '            <div style="width: 120px;height: 30px;margin-top: 15px;margin-left: 30px;">\n' +
                        '                <label style="font-size: 20px;color: #40AFFE;">我的信息</label>\n' +
                        '            </div>\n' +
                        '        </div>\n' +
                        '        <form class="layui-form">\n' +
                        '            <div style="width: 90%;height: 350px;position: absolute;right: 0;margin-top: 100px;margin-right: 1px;border-bottom: 1px solid gray;">\n' +
                        '                <div style="width: 85%;height: 40px;position: absolute;right: 0;margin-top: 50px">\n' +
                        '                <label style="font-size: 20px">昵称：</label><input value="'+$("#sname").html()+'" style="width: 300px;height: 30px;" type="text" name="sName" autocomplete="off" id="sName">\n' +
                        '                </div>\n' +
                        '                <div style="width: 85%;height: 40px;position: absolute;right: 0;margin-top: 120px;margin-right: 18px">\n' +
                        '                    <label style="font-size: 20px">用户名：</label><label>123213</label>\n' +
                        '                </div>\n' +
                        '                <div style="width: 85%;height: 40px;position: absolute;right: 0;margin-top: 180px;margin-right: 40px">\n' +
                        '                    <label style="font-size: 20px">我的签名：</label><textarea style="width: 500px"  class="layui-textarea" name="sIntroduction" id="sIntroduction">'+$("#sintroduction").html()+'</textarea>\n' +
                        '                </div>\n' +
                        '            </div>\n' +
                        '        </form>\n' +
                        '        <div style="width: 120px;height: 40px;position: absolute;right: 0;bottom: 0;margin-bottom: 15px;margin-right: 420px">\n' +
                        '            <button type="button" class="layui-btn layui-btn-normal" lay-submit lay-filter="demo1" style="width: 100px" id="submit">保存</button>\n' +
                        '        </div>'
                }
                $("#details").html(content);
            }
        })
    }
    layui.use(['form'],function (sId,sName,sAddress,sIntroduction) {
        var form = layui.form;
        form.on('submit(demo1)',function (data) {
            $.ajax({
                url:"Mydata/updateData",
                data:{
                    sId:1,
                    sName:$("#sName").val(),
                    sIntroduction:$("#sIntroduction").val()
                },
                success:function (data) {
                    alert("修改成功");
                }
            })
        })
    })



</script>

</body>
</body>
</html>